<?php

namespace App\Models;

class Notebook extends Base
{

    protected $casts = [
        'file_path' => 'array'
    ];
    protected $fillable = ['user_id', 'cookbook_id', 'message', 'file_path'];

    public function cookbook() {
        return $this->belongsTo(Cookbook::class, 'cookbook_id');
    }

    public function is_star() {
        return $this->hasOne(Star::class, 'entity_id')->where('type', Star::TYPE_NOTEBOOK);
    }

    public function user() {
        return $this->belongsTo(User::class, 'user_id');
    }

    public function is_focus() {
        return $this->hasOne(Focus::class, 'target_user_id', 'user_id');
    }



}
